Findstr command the Grep equivalent for Windows
It has been a while since I use a computer with Windows Operating System. However, I have no choice today since I'm working on a computer provided by client.
In the course of understanding the legacy codes....I need to search the legacy source codes with the grep command. Wait, there's no grep command in Windows!
A friend introduces this nifty tool - findstr
. The grep equivalent command in Windows world.
For example :
In Linux
$ ls -ls | grep filename
In Windows
c:\> dir | findstr filename
For multiple strings search with case insensitive example :
In Linux
$ ls -ls | grep -iE "testdata|lifo"
In Windows - empty space to replace pipe |
for multiple strings
c:\> dir | findstr -i "testdata lifo"
And to search through a list of file example
In Linux
$ grep searchtag -lr /path/directory
In Windows
c:\> findstr /M searchtag c:\directory\*
Hope this helps!
Reference :
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+12.3k Golang : Simple client-server HMAC authentication without SSL example
+20.2k Golang : Convert seconds to human readable time format example
+22.1k Golang : Repeat a character by multiple of x factor
+10.1k Golang : Get login name from environment and prompt for password
+22.7k Golang : Set and Get HTTP request headers example
+11.4k Golang : Concatenate (combine) buffer data example
+13.9k Golang : How to determine if a year is leap year?
+10.6k Golang : Simple File Server
+36.3k Golang : Convert(cast) int64 to string
+10.6k Golang : Flip coin example
+17.7k Golang : Parse date string and convert to dd-mm-yyyy format